<?php $this->load->view('common/admin_header');?>
<div class="block no_line">
  <div class="block_head">
    <div class="bheadl"></div>
    <div class="bheadr"></div>
    <h2><?=$lang['orders_lable_24']?></h2>
  </div>
  <div class="statistics">
      <table class="statistics_t" width="100%" cellspacing="0" cellpadding="0">
        <tbody>
          <tr>
            <td>
              <strong><?=isset($total_sms)?$total_sms:0?></strong> <?=$lang['orders_lable_25']?>
              <?php if($this->nsession->userdata('nick_name')=='clickr'):?>
              <a href="<?=site_url('admins/sms/recharge')?>" class="DetailsDOMWindow"><?=$lang['orders_lable_80']?></a>
              <?php endif;?>
            </td>
            <td><strong> <?=isset($yest_sms)?$yest_sms:0?> </strong> <?=$lang['orders_lable_26']?> </td>
            <td style="border-right:none;"><strong> <?=isset($today_sms)?$today_sms:0?> </strong> <?=$lang['orders_lable_27']?> </td>
          </tr>
        </tbody>
      </table>
  </div>
</div>
<div class="block">
  <div class="block_head">
    <div class="bheadl"></div>
    <div class="bheadr"></div>
    <h2><?=$lang['orders_lable_28']?></h2>
    <?php if($this->nsession->userdata('nick_name')=='clickr'):?>
    <ul>
      <li><a href="javascript:void(0);" onClick="delete_item('<?=site_url("admins/sms/delete_all")?>');"><?=$lang['orders_lable_81']?></a></li>
    </ul>
    <?php endif;?>
  </div>
  <!-- .block_head ends -->
  <div class="block_content">
    <?php $this->load->view('common/notify');?>
    <form action="<?=site_url('admins/sms')?>" method="get">
      <input type="hidden" name="field" value="<?=isset($field)?$field:'add_time'?>" id="field">
      <input type="hidden" name="sort" value="<?=isset($sort)?$sort:'desc'?>" id="sort">
      <table cellpadding="0" cellspacing="0" width="100%" class="sortable">
        <thead>
          <tr>
            <th><a id="send_date" class="<?=isset($field) && $field=='send_date'?$sort:'';?>" href="#"><?=$lang['orders_lable_29']?></a></th>
            <th><a id="phone_number" class="<?=isset($field) && $field=='phone_number'?$sort:'';?>" href="#"><?=$lang['orders_lable_30']?></a></th>
            <th><a id="message_txt" class="<?=isset($field) && $field=='message_txt'?$sort:'';?>" href="#"><?=$lang['orders_lable_31']?></a></th>
            <th><a id="phone_area" class="<?=isset($field) && $field=='phone_area'?$sort:'';?>" href="#"><?=$lang['orders_lable_32']?></a></th>
            <th><a id="send_result" class="<?=isset($field) && $field=='send_result'?$sort:'';?>" href="#"><?=$lang['orders_lable_33']?></a></th>
            <th style="text-align:center"><?=$lang['global_lable_32']?></th>
          </tr>
          <tr>
            <td>
              <input id="d4311" class="stext" type="text" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4312\')}',dateFmt:'yyyy-MM-dd HH:ss:mm',lang:'zh-tw'})" name="begin_month" value='<?=set_value('begin_month',isset($begin_month)?$begin_month:'')?>'/>
                <?=$lang['global_lable_46']?>
              <input id="d4312" class="stext" type="text" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}',dateFmt:'yyyy-MM-dd HH:ss:mm',lang:'zh-tw'})" name="end_month" value='<?=set_value('end_month',isset($end_month)?$end_month:'')?>'/>
            </td>
            <td><input type="text" class="stext" name="phone_number" lang="zh-TW" x-webkit-speech x-webkit-grammar="bUIltin:search" value="<?=isset($phone_number)?$phone_number:''?>"></td>
            <td>&nbsp;</td>
            <td>
              <select name="phone_area">
                <option value=""><?=$lang['orders_lable_34']?></option>
                <option value="客戶" <?=isset($phone_area) && $phone_area=='客戶'?'selected':''?> ><?=$lang['orders_lable_82']?></option>
                <option value="店主" <?=isset($phone_area) && $phone_area=='店主'?'selected':''?> ><?=$lang['orders_lable_83']?></option>
                <option value="推廣" <?=isset($phone_area) && $phone_area=='推廣'?'selected':''?> ><?=$lang['orders_lable_84']?></option>
              </select>
            </td>
            <td>
              <select name="send_result" id="send_result">
                <option value=""><?=$lang['orders_lable_35']?></option>
                <option value="成功" <?=isset($send_result)&&$send_result=='成功'?'selected':''?>><?=$lang['orders_lable_85']?></option>
                <option value="失敗" <?=isset($send_result)&&$send_result=='失敗'?'selected':''?>><?=$lang['orders_lable_86']?></option>
              </select>
            </td>
            <td style="text-align:center">
              <input type="submit" class="btn btn-small btn-primary" name="sub_filter" value="<?=$lang['global_lable_31']?>"/>
            </td>
          </tr>
        </thead>
        <tbody class="table">
          <?php if(isset($lists_count) && $lists_count>0):?>
          <?php foreach($lists->result_array() as $list):
            $urls=site_url('admins/sms/%s/'.$list['id']);
          ?>
          <tr>
            <td><?=date($format_time,$list['send_date'])?></td>
            <td title="<?=$list['phone_number']?>"><?=mb_substr($list['phone_number'],0,70,'utf-8')?>
              <?php if(mb_strlen($list['phone_number'])>70) echo '...';?></td>
            <td style="max-width:300px;" title="<?=$list['message_txt']?>"><?=mb_substr($list['message_txt'],0,70,'utf-8')?>
              <?php if(mb_strlen($list['message_txt'])>70) echo '...';?></td>
            <td><?=$list['phone_area']?></td>
            <td><?=$list['send_result']?></td>
            <td class="listaction">
              <?php if($this->nsession->userdata('nick_name')=='clickr'):?>
              <a href="javascript:void(0);" onClick="delete_item('<?=sprintf($urls,"delete")?>');" class="l_delete"><?=$lang['global_lable_25']?></a>
              <?php endif;?>
            </td>
          </tr>
          <?php endforeach;?>
          <?php else:?>
          <tr>
            <td colspan="9" class="nodata"><p><?=$lang['global_lable_42']?></p></td>
          </tr>
          <?php endif;?>
        </tbody>
      </table>
      <!-- .tableactions ends -->
      <div id="pagination"><?php echo $pagination;?><div class="listscount"><?=$lang['global_lable_29']?> <?=$lists_count?> <?=$lang['global_lable_30']?></div></div>
      <!-- .pagination ends -->
    </form>
  </div>
  <!-- .block_content ends -->
  <div class="bendl"></div>
  <div class="bendr"></div>
</div>
<!-- .block ends -->
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
  $('.DetailsDOMWindow').openDOMWindow({
    eventType:'click',  
    width:550,
    height:350,
    loaderImagePath:"<?=base_url('themes/admins/img/loading.gif')?>", 
    windowSource:'ajax', 
    windowHTTPType:'post' 
  });
})
</script>
<?php $this->load->view('common/admin_footer');?>